#!/bin/bash
# sudo yum -y install epel-release
sudo yum update - y
sudo yum install -y vim
# 安装ifconfig
sudo yum install net-tools -y
sudo yum install traceroute -y
# 时间同步
sudo yum install -y ntpdate
# 其他软件安装
sudo yum install wget -y
# 关闭SELinux、防火墙
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo setenforce 0
sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
# 禁用 swap
swapoff -a
sed -i 's/.*swap.*/#&/' /etc/fstab


# 配置内核参数，将桥接的IPv4流量传递到iptables的链
sudo cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

sudo sysctl --system

# iptables 设置
sudo iptables -P FORWARD ACCEPT
sudo iptables -nvL

# 安装docker（建议18.06.3）
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager \
 --add-repo \
 https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
## 列出Docker版本
sudo yum list docker-ce --showduplicates | sort -r
## 安装指定版本
sudo yum install -y docker-ce-18.06.1.ce-3.el7

sudo systemctl enable docker && sudo systemctl start docker
sudo docker -v

# 阿里docker 镜像加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://qm6k6mya.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

# 安装java环境
sudo tar -zxf /app/source/jdk-8u201-linux-x64.tar.gz -C /opt

echo "Config JAVA"
sudo sed -i '$a export JAVA_HOME="/opt/jdk1.8.0_201" \nPATH=$JAVA_HOME/bin:$PATH \nexport PATH\nCLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar\nexport CLASSPATH' /etc/profile
echo "Source profile"
sudo source /etc/profile
echo "---------------------------------"
java -version
echo JAVA_HOME: $JAVA_HOME
source /etc/profile

# 下载jvm 工具 arthas 
cd /app/source/
curl -O https://alibaba.github.io/arthas/arthas-demo.jar
curl -O https://alibaba.github.io/arthas/arthas-boot.jar


